home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / net / bind-contrib.tar.gz / bind-contrib.tar / contrib / misc / cachebuild.shar / cachebuild.awk next >
Encoding:
Text File  |  1996-10-25  |  1.3 KB  |  53 lines

  1. #
  2. # cachebuild.awk
  3. # Awk script for cachebuild, already designed to parse:
  4. #    nslookup output from pure BIND 4.8.3,
  5. #    nslookup that comes with SunOS 4.1.3.
  6. #
  7.  
  8. # Process NS RRs.  These give the names of the root domain servers.
  9.  
  10. $2=="nameserver" && $3=="=" {
  11.     roothost[$4] = 1;
  12. }
  13.  
  14. # Process A RRs.  These map domain server names to addresses.
  15. # Accumulate these into a space-delimited string; we will break them apart later.
  16. # Note that there may be more than one A RR per root server.
  17.  
  18. ($2=="inet" || $2=="internet") && $3=="address" && $4=="=" {
  19.     if (roothost[$1] == 1)
  20.         hostaddr[$1] = hostaddr[$1] " " $5;
  21. }
  22.  
  23. # Now that we parsed all the records, let's print the rest of the root cache.
  24. # We break the multiple address strings apart with the "split" function.
  25.  
  26. END {
  27.     print ";"
  28.     print "; Initial cache data for root domain servers."
  29.     print ";"
  30.     print ""
  31.     printf (".");
  32.     for (i in roothost) {
  33.         print "            99999999    IN    NS    " i ".";
  34.     }
  35.     print ""
  36.     print ";"
  37.     print "; Prep the cache (hotwire the addresses).  Order does not matter."
  38.     print ";"
  39.     print ""
  40.     for (i in hostaddr) {
  41.         ips = hostaddr[i];
  42.         n = split (ips, hstuff, " ");
  43.         for (j=1; j<=n; j++) {
  44.             printf ("%s.", i);
  45.             l = length (i ".");
  46.             if (l < 8) printf ("    ");
  47.             if (l < 16) printf ("    ");
  48.             if (l < 24) printf ("    ");
  49.             print "99999999    IN    A    " hstuff[j];
  50.         }
  51.     }
  52. }
  53.